package vip.meet.service.impl;

import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import vip.meet.cache.RedisCache;
import vip.meet.dao.bean.user.UserBean;
import vip.meet.dao.mapper.user.UserBeanMapper;
import vip.meet.datasource.DataSourceKey;
import vip.meet.service.UserService;


@Service
public class UserServiceImpl implements UserService {
    
    @Resource
    UserBeanMapper userBeanMapper;

    @DataSourceKey("master")
    @Override
    public int saveUserMaster(UserBean user) {
        return userBeanMapper.insertSelective(user);
    }

    @DataSourceKey("slave")
    @Override
    public int saveUserSlave(UserBean user) {
        return userBeanMapper.insertSelective(user);
    }

    @RedisCache(key="'user_'+#args[0]",clazz=UserBean.class)
    @Override
    public UserBean getUser(Integer id) {
        return userBeanMapper.selectByPrimaryKey(id);
    }

}
